#!/bin/bash
if(test -L $0) then auxlink=`ls -l $0 | sed 's/^[^>]*-> //g'`; M_HOME=`dirname $auxlink`/; else M_HOME=`dirname $0`/; fi; cd $M_HOME
. ../before || exit 1
sed -i 's/\(INSTALL.*=\).*/\1 install/' Makefile # INSTALL = install -o $(BIN_OWNER) -g $(BIN_GROUP) -> INSTALL = install
sb2 make
sb2 make ROOT=$ROOTFS install

cat > $ROOTFS/etc/inittab << EOF
id:3:initdefault:
si::sysinit:/etc/init.d/rcS
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
c0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100
EOF

cat > $ROOTFS/etc/init.d/rcS << EOF
#!/bin/sh
mount -t sysfs sysfs  /sys
mount -t tmpfs tmpfs  /dev
mount -t proc  proc   /proc
mount -t tmpfs tmpfs  /tmp
mknod /dev/console c 5 1
mknod /dev/null c 1 3
udevd --daemon
udevadm trigger
EOF

chmod 755 $ROOTFS/etc/init.d/rcS
touch $ROOTFS/.`basename $0`
